<template>
	<view class="container">
		<view class="background"></view>
		<navView navTitle="客户列表" backgroundColor="#008efe" titleColor="#fff" :isBack="true"></navView>
		<!-- 第一个用户信息 -->
		<view class="user-info" v-for="(user ,index) in userList" :key="index">
			<view class="user-header" @tap="$navTo('/subpkg/userList/detail?id=' + user.customer.id)">
				<view class="left">
					<image class="avatar" src="https://hfd.bjlzkj.com/static/user/ava.png" />
					<view class="user-details">
						<view class="username">{{ user.customer.name }}</view>
						<view class="status">状态：<text>{{ user.customer.follow}}</text> </view>
					</view>
				</view>
				<view class="options">
					<uni-icons type="right" size="30rpx" color="#909399" />
				</view>
			</view>
			<view class="stats">
				<view class="stat-item" @tap="$navTo('/subpkg/userList/project?type=1&id=' + user.customer.id)">
					<view>{{ user.completedProjects }}</view>
					<view>成交项目</view>
				</view>
				<view class="stat-item" @tap="$navTo('/subpkg/userList/project?type=2&id=' + user.customer.id)">
					<view>{{ user.pendingProjects }}</view>
					<view>意向项目</view>
				</view>
				<view class="stat-item">
					<view>{{ user.followUpRecords }}</view>
					<view>跟进记录</view>
				</view>
			</view>
			<view class="address">
				<view>地址：{{ user.customer.address || "暂无地址" }}</view>
			</view>
		</view>

		<!-- 添加按钮 -->
		<view class="add-button" @tap="$navTo('/subpkg/userList/add')">
			+
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userList: []
			}
		},
		onLoad() {

		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				this.$request('/addons/qingdong/customer/getResponsibleCustomerList', 'GET').then(res => {
					
					this.userList = res.data
					console.log(this.userList,'userlist')
				})
			},
			getStatus(status) {
				// 模拟状态样式
				if (status === '初级阶段') {
					return '初级阶段';
				} else if (status === '持续跟进') {
					return '持续跟进';
				}
			},
		},
	};
</script>

<style scoped lang="scss">
	.background {
		background: #f5f6f9;
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		z-index: -1;
	}

	.container {
		padding: 20rpx;
	}

	.user-info {
		background-color: #fff;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
		padding: 20rpx;
	}

	.user-header {
		display: flex;
		align-items: center;
		justify-content: space-between;

		.left {
			display: flex;
			align-items: center;
		}
	}

	.avatar {
		width: 81rpx;
		height: 81rpx;
		border-radius: 50%;
	}

	.user-details {
		margin-left: 20rpx;
	}

	.username {
		font-size: 32rpx;
		font-weight: bold;
	}

	.status {
		font-size: 24rpx;
		color: #ccc;

		text {
			color: #1890ff;
		}
	}

	.options {
		display: flex;
		align-items: center;
	}

	.stats {
		display: flex;
		justify-content: space-evenly;
		margin-top: 20rpx;
		background: #FBFBFB;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 15rpx;
	}

	.stat-item {
		text-align: center;
	}

	.stat-item view:first-child {
		font-size: 36rpx;
		font-weight: bold;
	}

	.stat-item view:last-child {
		font-size: 24rpx;
		color: #909399;
	}

	.address {
		font-size: 26rpx;
		margin-top: 35rpx;
	}

	.add-button {
		position: fixed;
		bottom: 120rpx;
		right: 50rpx;
		z-index: 10;
		background-color: #1890ff;
		border-radius: 50%;
		font-size: 120rpx;
		width: 120rpx;
		height: 120rpx;
		text-align: center;
		line-height: 100rpx;
		color: #fff;
	}
</style>